import  json
file_path = '身份证码值对照表.txt'
try:
    with open(file_path, 'r', encoding='utf8') as file:
        # location_dict = json.load(file)
        location_dict = json.loads(file.read())
        id = input('请输入身份证前6位查询属地：')
        if id == '' or len(id) != 6:
            print('身份码格式不正确，查询失败！')
        else:
            if id in location_dict:
                print(location_dict[id])
            else:
                print('未查找到该身份码信息')
except FileNotFoundError as fnfe:
    print(fnfe)

